package acm.pta13;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class 天梯赛的善良 {
    public static void main(String[] args) throws IOException {
        BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));
        int max = 0;
        int min = 1000000;
        int mincount = 0;
        int maxcount = 0;
        int n = Integer.parseInt(sc.readLine());
        String[] list = sc.readLine().split(" ");
        while (n-- > 0) {
            int shu = Integer.parseInt(list[n]);
            if (shu > max) {
                max = shu;
                maxcount = 1;
            } else if (shu == max) {
                maxcount++;
            }
            if (shu < min) {
                min = shu;
                mincount = 1;
            } else if (shu == min) {
                mincount++;
            }
        }
        System.out.println(min + " " + mincount);
        System.out.println(max + " " + maxcount);
    }
}

